# $Id: PKGBUILD 67469 2012-03-11 21:46:48Z lcarlier $
# Maintainer: Eric Belanger <eric@archlinux.org>

pkgname=colorgcc
pkgver=1.3.2
pkgrel=8
pkgdesc="A Perl wrapper to colorize the output of compilers with warning/error messages matching the gcc output format"
arch=('any')
url="http://www.schlueters.de/colorgcc.html"
license=('GPL')
depends=('perl')
backup=('etc/colorgcc/colorgccrc')
install=colorgcc.install
source=(http://mir1.ovh.net/gentoo-distfiles/distfiles/${pkgname}-${pkgver}.tar.gz colorgcc_1.3.2.0-10.diff)
md5sums=('7d62f92ab99c8271c79c40a0a470e8f7' '2811b14a96a1b4df72edab4c1b46ecdd')
sha1sums=('c2944ecaaa58f41f37cc15304f4f9eae0c366cd9' '8cd0924009198753b624165f2137ca23ff707578')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 < ../colorgcc_1.3.2.0-10.diff
  patch -p1 < debian/patches/005_old_changes.patch
  patch -p1 < debian/patches/01_split_non_quoted.patch
  patch -p1 < debian/patches/02_stderr.patch
  patch -p1 < debian/patches/03_color_warnings.patch
  patch -p1 < debian/patches/04_g++_color.patch
  patch -p1 < debian/patches/05_console-colors.patch
  patch -p1 < debian/patches/06_use_distcc.patch
  patch -p1 < debian/patches/07_invalid_attr.patch
  patch -p1 < debian/patches/08_force_color_opt.patch
  patch -p1 < debian/patches/09_color_warnings.patch
  patch -p1 < debian/patches/10_utf8_output.patch
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  install -D -m755 colorgcc "${pkgdir}/usr/bin/colorgcc"
  install -D -m644 colorgccrc "${pkgdir}/etc/colorgcc/colorgccrc"
  install -D -m644 debian/colorgccrc.5 "${pkgdir}/usr/share/man/man5/colorgccrc.5"
  install -D -m644 debian/colorgcc.1 "${pkgdir}/usr/share/man/man1/colorgcc.1"

  install -d "${pkgdir}/usr/lib/colorgcc/bin"
  for i in cc c++ gcc g++ ; do
    ln -s /usr/bin/colorgcc "${pkgdir}/usr/lib/colorgcc/bin/${i}"
  done
}
